//
//  JSQNewMessageView.m
//  Conversation
//
//  Created by C_HAO on 16/4/6.
//  Copyright © 2016年 CHAOO. All rights reserved.
//

#import "JSQNewMessageView.h"

@interface JSQNewMessageView ()

@property(nonatomic, strong) UILabel *label;

@end


@implementation JSQNewMessageView

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        self.userInteractionEnabled = YES;

        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 16.5f;

        self.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.900];

        UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touch:)];
        [self addGestureRecognizer:tapGestureRecognizer];

        _label = [[UILabel alloc] init];
        _label.translatesAutoresizingMaskIntoConstraints = NO;
        _label.text = @"新消息";
        _label.font = [UIFont systemFontOfSize:15];
        _label.textAlignment = NSTextAlignmentCenter;
        _label.textColor = [UIColor whiteColor];

        [self addSubview:_label];

        [self addConstraint:[NSLayoutConstraint constraintWithItem:_label attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1 constant:0]];
        [self addConstraint:[NSLayoutConstraint constraintWithItem:_label attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1 constant:0]];
        [self addConstraint:[NSLayoutConstraint constraintWithItem:_label attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1 constant:0]];
        [self addConstraint:[NSLayoutConstraint constraintWithItem:_label attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
    }
    return self;
}

- (void)touch:(id)sender {
    (_touch) ? _touch(self) : nil;
}

@end
